<%@page import="java.lang.Object"%>
<%@page import="classes.HomeworkLecturer"%>
<%@page import="classes.HomeworkManagerLecturer"%>
<%@page import="classes.SubjectManager"%>
<%@page import="classes.GroupManager"%>
<%@page import="classes.AccountManager"%>
<%@page import="classes.User"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<%
	String groupName = request.getParameter("groupName");
	String subject_name = request.getParameter("subject");
%>
<title>HomeWork Of <%=groupName%></title>
</head>
<body>
	<center>
		<h2>
			Homeworks of
			<%=groupName%>
			at
			<%=subject_name%>
		</h2>
	</center>
	<%
		GroupManager gmanager = (GroupManager) getServletContext()
				.getAttribute(GroupManager.GROUPMANAGER);
		SubjectManager smanager = (SubjectManager) getServletContext()
				.getAttribute(SubjectManager.SUBJECTMANAGER);
		int subject_id = smanager.getSubjectId(subject_name);
		int group_id = gmanager.getGroupId(groupName, subject_id);
	%>

	<center>
		<table border="15">
			<tr>
				<th>Homework Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
				<th>Start Date&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
				<th>DeadLine&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
				<th>Homework Attachment&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
				<th>Students Homework&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
				<th>Delete Homework&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
			</tr>
			<%
				User user = (User) session.getAttribute("user");
				HomeworkManagerLecturer hmanager = (HomeworkManagerLecturer) getServletContext()
						.getAttribute(
								HomeworkManagerLecturer.HOMEWORKMANAGERLECTURER);
				HomeworkLecturer[] homeworks = hmanager.getHomeworks(group_id);
				for (int i = 0; i < homeworks.length; i++) {
					out.println("<tr> " + "<td> " + homeworks[i].getHomeworkName()
							+ "</td>" + "<td>" + homeworks[i].getStartTime()
							+ "</td>" + "<td>" + homeworks[i].getEndTime()
							+ "</td>" + "<td>" + "<a href =\""
							+ homeworks[i].getFile()
							+ "\"target=\"_blank\">>Download file</a></td>"
							+ "<td>" + "<a href=\"showHomeworks.jsp?homework_id="
							+ homeworks[i].getHomeworkID()
							+ "\" >Show Homework</a>" + "</td>" + "<td>"
							+ "<a href=\"deleteHomework.jsp?group_name="
							+ groupName + "&subject=" + subject_name
							+ "&homework_id=" + homeworks[i].getHomeworkID() + "\""
							+ ">Delete This Homework</a>" + "</td>" + "</tr>");
				}
			%>
		</table>
	</center>
	<p>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;
		<a
			href="addingHomework.jsp?group_id=<%=group_id%>&groupName=<%=groupName%>&subject=<%=subject_name%>">Add
			HomeWork</a>
	<p>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		&nbsp;&nbsp;&nbsp;&nbsp;
		<a
			href="groupsForLectures.jsp?subject_id=<%=subject_id%>&id=<%=user.getUserId()%>&subject=<%=subject_name%>">Go
			Back</a>
	</p>
	</p>
</body>
</html>